﻿using System;
using System.Web.UI;
using EPiServer;

namespace Jungle.Templates.Jungle.MasterPages
{
    public partial class Site : MasterPage
    {
        private const string _title = "{0}{1}{2}";
        private string _titleSeperator = " - ";
        public string TitleSeperator
        {
            get { return _titleSeperator; }
            set { _titleSeperator = value; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            var page = (PageBase) Page;
            Page.Title = string.Format(_title, page.CurrentPage.Property["PageName"].ToWebString(), TitleSeperator,
                                       EPiServer.Configuration.Settings.Instance.SiteDisplayName);

            this.HtmlElement.Attributes["lang"] = page.CurrentPage.LanguageBranch;
        }
    }
}
